package com.tuling.jvm;
//常见面试题
public class Example {
    public static void main(String[] args) {
        String s0="zhuge";
        String s1="zhuge";
        String s2="zhu" + "ge"; //jvm在运行时会自动拼接zhuge
        System.out.println( s0==s1 ); //true
        System.out.println( s0==s2 ); //true
        System.out.println("-----------------------");

        String s3="zhuge";
        String s4=new String("zhuge");
        String s5="zhu" + new String("ge"); //有new的话，JVM运行时不会自动拼接成zhuge
        System.out.println( s3==s4 ); //false
        System.out.println( s3==s5 ); //false
        System.out.println( s4==s5 ); //false
        System.out.println("-----------------------");

        String a = "a1";
        String b = "a" + 1;
        System.out.println(a == b); //true
        String c = "ctrue";
        String d = "c" + "true";
        System.out.println(c == d); //true
        String e = "e3.4";
        String f = "e" + 3.4;
        System.out.println(e==f); //true
    }
}
